home *** CD-ROM | disk | FTP | other *** search
- on exportText textString
- if the machineType = 256 then
- openXLib("dialogs.dll")
- set dialog to dialogs(mnew)
- else
- set dialog to dialogs(mnew)
- end if
- if the machineType = 256 then
- set fname to dialog(mPutFile, "Export File", EMPTY, "*.txt")
- else
- set fname to dialog(mPutFile, "Export File", EMPTY)
- end if
- if fname <> EMPTY then
- if the machineType = 256 then
- openXLib("fileio.dll")
- set File to FileIO(mnew, "write", fname)
- else
- set File to FileIO(mnew, "write", fname)
- end if
- if not objectp(File) then
- alert("Unable to save file. Please check available disk space.")
- else
- set MAXLEN to 80
- if the machineType = 256 then
- set CRLF to RETURN & numToChar(10)
- else
- set CRLF to EMPTY
- end if
- set textLen to the number of chars in textString
- set textLines to the number of lines in textString
- if the machineType = 256 then
- set textString to breakIntoLines(textString)
- end if
- set numLines to the number of lines in textString
- put numLines
- if the machineType = 256 then
- repeat with i = 1 to numLines
- File(mWriteString, line i of textString & CRLF)
- end repeat
- else
- File(mWriteString, textString)
- end if
- File(mdispose)
- return 1
- end if
- else
- return 0
- end if
- if the machineType = 256 then
- dialogs(mdispose)
- else
- dialogs(mdispose)
- end if
- end
-
- on breakIntoLines textString
- set MAXLEN to 80
- set rString to EMPTY
- set rLines to 0
- set numLines to the number of lines in textString
- repeat with myLine = 1 to numLines
- if the number of chars in line myLine of textString > MAXLEN then
- set testLine to line myLine of textString
- repeat while the number of chars in testLine > MAXLEN
- if alphanum(char MAXLEN of testLine) and alphanum(char MAXLEN + 1 of testLine) then
- set end to findBreakpoint(testLine, MAXLEN)
- if end <> 0 then
- put char 1 to end of line myLine of testLine after rString
- put RETURN after rString
- set begin to end + 1
- set end to the number of chars in testLine
- set testLine to char begin to end of testLine
- else
- put char 1 to MAXLEN of line myLine of testLine after rString
- put RETURN after rString
- set begin to MAXLEN + 1
- set end to the number of chars in testLine
- set testLine to char begin to end of testLine
- end if
- next repeat
- end if
- put char 1 to MAXLEN of line myLine of testLine after rString
- put RETURN after rString
- set begin to MAXLEN + 1
- set end to the number of chars in testLine
- set testLine to char begin to end of testLine
- end repeat
- if the number of chars in testLine > 0 then
- put testLine after rString
- end if
- next repeat
- end if
- put line myLine of textString after rString
- end repeat
- return rString
- end
-
- on alphanum ch
- if (charToNum(ch) > 32) and (charToNum(ch) < 127) then
- return 1
- else
- return 0
- end if
- end
-
- on findBreakpoint textString, length
- set SPACE to " "
- repeat with i = length down to 1
- if char i of textString = SPACE then
- return i
- end if
- end repeat
- return 0
- end
-